#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Student {
    int a, b, c, index;
    int rank;
};

bool cmp(const Student& a, const Student& b) {
    if (a.a + a.b + a.c != b.a + b.b + b.c) {
        return a.a + a.b + a.c > b.a + b.b + b.c;
    }
    if (a.a + a.b != b.a + b.b) {
        return a.a + a.b > b.a + b.b;
    }
    return max(a.a, a.b) > max(b.a, b.b);
}

void solve(){
    int n;
    cin >> n;
    Student stu[10005];
    
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        stu[i] = {a, b, c, i};
    }
    
    sort(stu + 1, stu + 1 + n, cmp);
    
    if (n == 0) {
        return;
    }
    stu[1].rank = 1;
    int cnt = 1,cnt1 = 1;
    
    for (int i = 2; i <= n; ++i) {
        Student& p1 = stu[i-1];
        Student& p2 = stu[i];
        if (p1.a + p1.b + p1.c == p2.a + p2.b + p2.c && 
            p1.a + p1.b == p2.a + p2.b && 
            max(p1.a, p1.b) == max(p2.a, p2.b)) {
            cnt1++;
            p2.rank = cnt;
        } else {
            cnt += cnt1;
            cnt1 = 1;
            p2.rank = cnt;
        }
    }
    
    sort(stu + 1, stu + 1 + n, [](const Student& a, const Student& b) {
        return a.index < b.index;
    });
    
    for (int i = 1; i <= n; i++) {
        cout << stu[i].rank << endl;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
